<template>
	<view>
		<view class="user_wrap">
			<image :src="'http://127.0.0.1:3000'+Cpic"></image>
			<view>
					<view v-if="nickName">{{nickName}}</view>
				
					<view v-if="!nickName"  @click="toLogin">点击登录</view>
					<view  v-if="nickName" @click="quitLogin">退出登录</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {quitApi} from '@/api/common.js'
	export default {
			data(){
				return {
					nickName:"",
					Cpic:"",
					userName:""
					
				}
			},
		onShow(){
			let user=uni.getStorageSync("user");
			console.log(user,"----888888888--------")
			if(user.tokenId){
				this.nickName=user.nickName
				this.Cpic=user.userPic;
				this.userName=user.userName;
			}
		},
		methods:{
			
			toLogin(){
				uni.navigateTo({
					url:"/pages/mine/login"
				})
			},
			async quitLogin(){ //退出登录接口
				// let res=await quitApi(this.userName);
				// console.log(res,"^^^^^^^^^^^");
				uni.setStorageSync("user",{});
				uni.showToast({
					title:"退出成功"
				})
				this.nickName=""
				this.Cpic="";
				this.userName="";
			}
		}
	}
</script>

<style lang="scss">
	.user_wrap{
		display: flex;
		height: 280px;
		align-items: center;
		justify-content: space-around;
		font-size: 30px;
		image{
			width: 200px;
			height: 200px;
			border-radius: 50%;
			border: 1px solid black;
		}
	}
</style>